using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using ClassBuilderWizard.Interfaces;

namespace ClassBuilderWizard.DefaultPlugins.Forms
{
    public partial class frmMSSQLWizardStep1 : WizardFormBase
    {
        public frmMSSQLWizardStep1()
        {
            InitializeComponent();
        }

        public bool GenerateDataComponents
        {
            get { return chkDataComponents.Checked; }
        }
        public bool UseObjectNameAsClassName
        {
            get { return chkObjectName.Checked; }
        }
        public bool PreserveNulls
        {
            get { return chkPreserveNulls.Checked; }
        }


        public string ConnectionString
        {
            get { return txtConnection.Text; }
        }

        private void btnNewConnection_Click(object sender, EventArgs e)
        {
            frmMSSQLConnection f = new frmMSSQLConnection(this.txtConnection.Text.Trim());
            if (f.ShowDialog(this) == DialogResult.OK)
            {
                this.txtConnection.Text = f.DatabaseConnection;
            }
        }

        private void txtConnection_TextChanged(object sender, EventArgs e)
        {
            this.btnNext.Enabled = (this.txtConnection.Text.Trim() != string.Empty);
        }

        private void frmMSSQLWizardStep1_Load(object sender, EventArgs e)
        {
            //try to get the last database connection string from the registry
            RegistryHelper rh = new RegistryHelper();
            txtConnection.Text = rh.GetLastConnection();
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            RegistryHelper rh = new RegistryHelper();
            rh.SaveLastConnection(txtConnection.Text);
        }
    }
}